/*
 * CHttpService.h
 *
 *  Created on: 2018年1月8日
 *      Author: terry
 */

#ifndef CHTTPSERVICE_H_
#define CHTTPSERVICE_H_

#include "HttpRestServer.h"
#include "json/json.h"
#include <memory>
#include "DbConnectionPool.h"
#include "RestHttpHandler.h"
#include "StringMap.h"



class CHttpService: public HttpRestServer
{
public:
	CHttpService();
	virtual ~CHttpService();

	void setDb(std::shared_ptr< db::DbConnectionPool >& dbPool);

    virtual bool start(int port);

    virtual void stop();

    virtual bool isStarted();

    virtual void broadcast(const char* data, size_t len);

    virtual void broadcast(const std::string& data);

    virtual int getPort();


	std::string getWebsitePath();
	std::string getLogPath();

protected:
    void setupUri();

protected:
    int listDeviceGps(HttpRequest& request, HttpResult& result);
    int listDeviceStatus(HttpRequest& request, HttpResult& result);

protected:

public:

protected:


protected:
	

protected:
    std::shared_ptr<HttpServer>     m_server;
	int	m_port;

	std::shared_ptr< db::DbConnectionPool >	m_dbPool;


};

#endif /* CHTTPSERVICE_H_ */
